
#ifndef __CLUSTER_SSH_DB_H
#define __CLUSTER_SSH_DB_H

#include <vector>
#include "../crypt/KeyPair.h"
#include "SQLiteDB.h"

// handle char(64)
// keydata char(4096)

class ClusterSSHDB : public SQLiteDB
{
   public:
      ClusterSSHDB(const char *filename) : SQLiteDB(filename, 1) { CreateTablesIfNecessary(); }
      ~ClusterSSHDB();
      char *UnaliasHostName(const char *maybeanalias);
      std::vector<char *> *getSetOfActiveKeysForUser(const char *sso_userid);
      char *GetListOfClustersForUser(const char *sso_userid);
      char *GetHostForClusterForUser(const char *sso_userid, const char *clusterid, std::vector<char *> *blacklist);
      std::vector<char *> *GetPathFromSourceToCluster(const char *sso_userid, const char *clusterid, std::vector<char *> *blacklist);
      std::vector<char *> *GetPathFromSourceToHost(const char *sso_userid, const char *hostname, std::vector<char *> *blacklist);
      int IsTrue(const char *result);
      void MergeXMLWithClusterDB(const char *xmlfile);
      int GetClusterNodeWeight(const char *clusterid);
      std::vector<char *> *GetHostsWithBrokenKeys(const char *broker_username);
      int BooleanCanLogInWithKey(const char *broker_username, const char *host);
      char *CanLogInWithKey(const char *broker_username, const char *host);
      char *GetLogInNameForHostForUser(const char *broker_username, const char *host);
      void ChangeLogInKeyNameForUser(const char *broker_username, const char *newkeyname, const char *host);
      void DeleteLogInDetails(const char *broker_username, const char *host);
      void CreateLogInDetails(const char *broker_username, const char *host, const char *host_username);
      int BooleanIsHostAccessibleByUser(const char *sso_userid, const char *hostname);
      int BooleanIsHostSource(const char *hostname);
      int BooleanDoesHostExist(const char *hostname);
      int BooleanDoesConnectionIDExist(const char *connid);
      void CreateUserTable(const char *username);
      void UpdateKeyFingerprint(const char *keyfingerprint, const char *hostname);
      char *GetKeyFingerprint(const char *hostname);
      void CreateHostEntry(const char *hostname, int port);
      void CreateTablesIfNecessary();
};

#endif
